import sys

if hasattr(sys,"setdefaultencoding"):
        sys.setdefaultencoding("utf-8")

from core import log


from mainForm import *
from PyQt4 import QtCore,QtGui
from core import init_modules,uicomponents,constants


if __name__ == "__main__":

	import psyco
	psyco.log()
	psyco.profile()
	psyco.full()
	
	log.logger.info('-----------------------------------\n\n\n\n\n\n\t\t\t\t')
	log.logger.info('Starting Application...')

	arguments =sys.argv
	arguments.append('-style')
	arguments.append('plastique')

	app = QtGui.QApplication(sys.argv)
	app.setLayoutDirection(QtCore.Qt.RightToLeft)

	log.logger.debug('Showing Splash Screen')
	splashScreen = QtGui.QSplashScreen(QtGui.QPixmap(constants.app_path+'\images\splash.bmp'))
	splashScreen.show()

	log.logger.debug('Creating main maindow')
	MainWindow = QtGui.QMainWindow()
	uicomponents.SharedUi.mainWindow = MainWindow
	log.logger.debug('Init all modules')
	init_modules.initModules()	

	log.logger.debug('Setting up ui')
	ui = Ui_MainWindow()
	ui.setupUi(MainWindow)
	MainWindow.showFullScreen()
    
	splashScreen.finish(MainWindow)
	
	sys.exit(app.exec_())
	log.logger.info('Ending Application!')
